import 'package:flutter/material.dart';
void main() => runApp(MyApp());
 
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Material App Bar'),
        ),
        body: HomePages(),
      ),
    );
  }
}
// 简写 statef
class HomePages extends StatefulWidget {
  HomePages({Key key}) : super(key: key);

  _HomePagesState createState() => _HomePagesState();
}

class _HomePagesState extends State<HomePages> {
  int nums = 0;
  List list = new List();
  @override
  Widget build(BuildContext context) {
    return Container(
       child: ListView(
         children: <Widget>[
           Column(
             children: this.list.map((value){
               return ListTile(
                 title: Text(value),
               );
             }).toList(),
           ),
           SizedBox(height: 20,),
           RaisedButton(
             child: Text("button"),
             onPressed: (){
               setState(() {
                  this.nums++;
                  this.list.add("value${this.nums}");
               });
             },
           )
         ],
       ),
    );
  }
}



class HomePage extends StatefulWidget {
  HomePage({Key key}) : super(key: key);

  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int countNum = 0;
  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        Chip(
          label: Text("你好${this.countNum}"),
        ),
        SizedBox(height: 30,),
        Text("${this.countNum}"),
        SizedBox(height: 20,),
        RaisedButton(
          child: Text("button"),
          onPressed: (){
            setState(() {
              this.countNum++;
            });
          },
        )
      ],
    );
  }
}